<script setup>
import userStore from '../store'

const { todos } = userStore()
</script>
<template>
  <!-- This section should be hidden by default and shown when there are todos -->
  <section class="main">
    <input
      id="toggle-all"
      class="toggle-all"
      type="checkbox"
      :checked="todos.isCheckAll"
      @click="todos.checkoutAll(!todos.isCheckAll)"
    />
    <label for="toggle-all">Mark all as complete</label>
    <ul class="todo-list">
      <!-- These are here just to show the structure of the list items -->
      <!-- List items should get the class `editing` when editing and `completed` when marked as completed -->
      <li
        :class="{ completed: item.done }"
        v-for="item in todos.getListByType"
        :key="item.id"
      >
        <div class="view">
          <input
            class="toggle"
            type="checkbox"
            :checked="item.done"
            @click="todos.changeDone(item.id)"
          />
          <label>{{ item.name }}</label>
          <button class="destroy" @click="todos.handleDel(item.id)"></button>
        </div>
        <input class="edit" value="Create a TodoMVC template" />
      </li>
    </ul>
  </section>
</template>
